123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- "use client";
- import { UserInfoRep, UserVipInfo, Wallet } from "@/api/user";
- import TipsModal, { ModalProps } from "@/components/TipsModal";
- import { Link, useRouter } from "@/i18n/routing";
- import { useWalletStore } from "@/stores/useWalletStore";
- import { WalletEnum } from "@/types";
- import { vipImages } from "@/utils/constant";
- import { flatPoint, percentage } from "@/utils/methods";
- import { ProgressBar, Toast } from "antd-mobile";
- import { useTranslations } from "next-intl";
- import Image from "next/image";
- import { Fragment, useRef, useState } from "react";
- type Props = {
- userInfo: UserInfoRep;
- userMoney: Wallet;
- userVip: UserVipInfo;
- };
- const VipCard = (props: { userVip: UserVipInfo }) => {
- const { userVip } = props;
- const t = useTranslations("ProfilePage");
- // Vip 图标
- const vipIconElement = vipImages.map((item, index) => {
- if (item.leve === userVip.vip_level) {
- return (
- <Fragment key={index}>
- <Image src={item.src} alt={"vip"} height={110} width={100} />
- <span className={"icon-level"} style={{ color: item.color }}>
- {item.leve}
- </span>
- </Fragment>
- );
- }
- });
- return (
- <div className={"vip-card"}>
- <div className={"vip-card__icon"}>{vipIconElement}</div>
- <div className={"vip-card-process"}>
- {/*<div className={"process-top"}>{userVip.vip_exp}xp</div>*/}
- <div>
- <ProgressBar
- percent={percentage(userVip.vip_exp, userVip.vip_score_exp)}
- style={{
- "--fill-color": "#fb8b05",
- "--track-width": "0.0694rem",
- }}
- />
- </div>
- <div className={"process-bottom"}>
- <span>VIP{userVip.vip_level}</span>
- <span className={"process-bottom-desc"}>
- {t("expTips", {
- exp: flatPoint(userVip.vip_score_exp - userVip.vip_exp),
- })}
- </span>
- <span>
- VIP
- {userVip.vip_next_level}
- </span>
- </div>
- </div>
- </div>
- );
- };
- const Progress = (props: { percent: number }) => {
- const { percent } = props;
- return (
- <div className="flex">
- <ProgressBar
- percent={percent}
- className={"mr-[0.0694rem] flex-1"}
- style={{
- "--fill-color": "var(--primary-color)",
- "--track-width": "0.0694rem",
- }}
- />
- <span className={"text-primary-color"}>{percent}%</span>
- </div>
- );
- };
- const WalletContent = (props: {
- percentage: number;
- type: string;
- difference: number;
- current: number;
- }) => {
- const { percentage, type, difference, current } = props;
- const t = useTranslations("ProfilePage");
- return (
- <div>
- <div className={"mb-[0.12rem] text-[0.12rem]"}>
- <span className={"mr-[10px]"}>{type}</span>
- <i className={"mr-[10px] indent-[10px] text-[0.1528rem] font-bold"}>R$</i>
- <span>{current}</span>
- </div>
- <Progress percent={percentage} />
- <div>
- <span>{t("modalBottomTips")}</span>
- <span>{difference.toFixed(2)}</span>
- </div>
- </div>
- );
- };
- // 现金
- const BalanceContent = (props: { wallet: Wallet }) => {
- const { wallet } = props;
- const t = useTranslations("ProfilePage");
- return (
- <>
- <WalletContent
- difference={wallet.target_score_rollover - wallet.current_score_rollover}
- type={t("balance")}
- current={wallet.score || 0}
- percentage={percentage(wallet.current_score_rollover, wallet.target_score_rollover)}
- />
- </>
- );
- };
- const BonusContent = (props: { wallet: Wallet }) => {
- const { wallet } = props;
- const t = useTranslations("ProfilePage");
- return (
- <div>
- <WalletContent
- difference={wallet.target_point_rollover - wallet.current_point_rollover}
- type={t("bonus")}
- current={wallet.point || 0}
- percentage={percentage(wallet.current_point_rollover, wallet.target_point_rollover)}
- />
- <p className={"text-center"}>{t("bonusArticle")}</p>
- <ul className={"ml-[0.1389rem] list-decimal text-[0.12rem] text-[#666]"}>
- <li>{t("bonusDesc1")}</li>
- <li>{t("bonusDesc2")}</li>
- <li>{t("bonusDesc3")}</li>
- </ul>
- </div>
- );
- };
- const FreeContent = (props: { wallet: Wallet }) => {
- const { wallet } = props;
- const t = useTranslations("ProfilePage");
- return (
- <div>
- <WalletContent
- difference={wallet.target_free_score_rollover - wallet.current_free_score_rollover}
- type={t("free")}
- current={wallet.free_score || 0}
- percentage={percentage(
- wallet.current_free_score_rollover,
- wallet.target_free_score_rollover
- )}
- />
- <p className={"text-center"}>{t("freeArticle")}</p>
- <ul className={"ml-[0.1389rem] list-decimal text-[0.12rem] text-[#666]"}>
- <li>{t("freeDesc1")}</li>
- <li>{t("freeDesc2")}</li>
- </ul>
- </div>
- );
- };
- const ReplayContent = (props: { wallet: Wallet }) => {
- const { wallet } = props;
- const t = useTranslations("ProfilePage");
- return (
- <div>
- <WalletContent
- difference={wallet.target_lose_score_rollover - wallet.current_lose_score_rollover}
- type={t("replay")}
- current={wallet.lose_score || 0}
- percentage={percentage(
- wallet.current_lose_score_rollover,
- wallet.target_lose_score_rollover
- )}
- />
- <p className={"text-center"}>{t("replayArticle")}</p>
- <ul className={"ml-[0.1389rem] list-decimal text-[0.12rem] text-[#666]"}>
- <li>{t("replayDesc1")}</li>
- <li>{t("replayDesc2")}</li>
- </ul>
- </div>
- );
- };
- const WalletCard = (props: { userMoney: Wallet }) => {
- const { userMoney } = props;
- const t = useTranslations("ProfilePage");
- const tipsRef = useRef<ModalProps>(null);
- const [tipsStatus, setTipsStatus] = useState<keyof typeof WalletEnum>("Bonus");
- const modalHandler = (key: keyof typeof WalletEnum) => {
- setTipsStatus(key);
- tipsRef.current?.onOpen();
- };
- return (
- <>
- <TipsModal
- ref={tipsRef}
- title={
- <div className={"flex items-center"}>
- <i
- className={"iconfont icon-liwuhuodong mr-[0.0694rem] text-[0.2778rem]"}
- ></i>
- {t("modalTitle")}
- </div>
- }
- >
- {/*现金*/}
- {tipsStatus === WalletEnum.Balance ? <BalanceContent wallet={userMoney} /> : null}
- {/* 彩金*/}
- {tipsStatus === WalletEnum.Bonus ? <BonusContent wallet={userMoney} /> : null}
- {/* 免费币 */}
- {tipsStatus === WalletEnum.Free ? <FreeContent wallet={userMoney} /> : null}
- {/* 重玩币 */}
- {tipsStatus === WalletEnum.Replay ? <ReplayContent wallet={userMoney} /> : null}
- </TipsModal>
- <div className="coin">
- <span className="coin_left__icon iconfont icon-icon-wallet"></span>
- <div className={"coin_right_wallet"}>
- <div
- className={"wallet_left_border"}
- onClick={() => modalHandler(WalletEnum.Balance)}
- >
- <div className={"wallet_header"}>
- <span>{t("balance")}</span>
- <Image
- className="wallet_header__icon"
- src="/img/a.png"
- alt="question"
- width={15}
- height={15}
- />
- </div>
- <div className="num">
- <span className="uppercase">brl </span>
- <span>{userMoney.score || 0.0}</span>
- </div>
- </div>
- <div
- className={"wallet_right_content"}
- onClick={() => modalHandler(WalletEnum.Bonus)}
- >
- <div className={"wallet_header"}>
- {t("bonus")}
- <Image
- className="wallet_header__icon"
- src="/img/a.png"
- alt="question"
- width={15}
- height={15}
- />
- </div>
- <div className="num">
- <span className="uppercase">brl </span>
- <span>{userMoney.point || 0.0}</span>
- </div>
- </div>
- <div
- className={"wallet_left_border"}
- onClick={() => modalHandler(WalletEnum.Free)}
- >
- <div className={"wallet_header"}>
- {t("free")}
- <Image
- className="wallet_header__icon"
- src="/img/a.png"
- alt="question"
- width={15}
- height={15}
- />
- </div>
- <div className="num">
- <span className="uppercase">brl </span>
- <span>{userMoney.free_score || 0.0}</span>
- </div>
- </div>
- <div
- className={"wallet_right_content"}
- onClick={() => modalHandler(WalletEnum.Replay)}
- >
- <div className={"wallet_header"}>
- {t("replay")}
- <Image
- className="wallet_header__icon"
- src="/img/a.png"
- alt="question"
- width={15}
- height={15}
- />
- </div>
- <div className="num">
- <span className="uppercase">brl </span>
- <span>{userMoney.lose_score || 0.0}</span>
- </div>
- </div>
- </div>
- </div>
- </>
- );
- };
- export const ProfileHeader = (props: Props) => {
- const { userInfo, userVip } = props;
- const t = useTranslations("ProfilePage");
- const wallet = useWalletStore((state) => state.wallet);
- const router = useRouter();
- const handler = () => {
- if (!!wallet.score) {
- router.push("/withdraw");
- } else {
- Toast.show("no money ");
- }
- };
- return (
- <>
- <div className={"userContent"}>
- <div className={"userInfo"}>
- <div>
- <div className={"bgImg"}>
- <Image
- src={"/img/avatar.png"}
- className={"h-[100%] w-[100%]"}
- alt={"avatar"}
- width={120}
- height={120}
- />
- </div>
- <div>
- <span>{t("Conta")}</span>
- <span className="phone">{userInfo?.user_phone || ""}</span>
- </div>
- </div>
- <Link className="goto iconfont icon-xiangzuo1" href={`/changePassword`}></Link>
- </div>
- {/*vipcard*/}
- <VipCard userVip={userVip} />
- <WalletCard userMoney={wallet} />
- </div>
- <div className="link">
- <Link href={"/deposit"} className={"btn"}>
- {t("Depósito")}
- </Link>
- <p className={"btn"} onClick={handler}>
- {t("Sacar")}
- </p>
- </div>
- </>
- );
- };
|